import gorila
import sys

if len(sys.argv) < 2:
    sys.stderr.write('\n \
Usage: pytohn teste.py [-d teachers per degree and per year] <degree> <year> \n \
			[-e teachers per establishment and per year] <year> <establishment> \n \
			[-dE teachers per degree, per establishment and per year] <degree> <establishment> <year> \n \
			[-y teachers in the higher education system per year] <year>\n \
			[-lists generate lists] <degree> <establishment> <year>\n\n')

else:
	#print(len(sys.argv))

	#print sys.argv[1]
	for i in range(1,len(sys.argv)):
		if(sys.argv[i]=="-y"):
			s = sys.argv[i+1]
			c = int(s[3])
			
			b = gorila.count_teachers(c)

			print "\n numero total de docentes no ano 200{0}: {1}\n".format(c,b)
			
		if(sys.argv[i]=="-lists"):
			s = sys.argv[i+3]
			c = int(s[3])
			
			
			
			f = gorila.make_list_estab(c)
			
			print "\n Estabelecimentos no ano 200{0}:\n".format(c)
			for name in f:
				print "	 {0}\n".format(name)
			
			
			
			g = gorila.make_list_docente_degree(c, "'{0}'".format(sys.argv[i+1]))
			
			print "\n Lista docentes com grau {0} no ano 200{1}:\n".format(sys.argv[i+1], c)
			for name in g:
				print "	 {0}\n".format(name)



			h = gorila.make_list_personnel_leaving("'{0}'".format(sys.argv[i+2]))
			
			print "\n Numero de docentes que sairam nos varios anos no estabelecimento {0}:\n".format(sys.argv[i+2])
			for num in h:
				print "	 {0}\n".format(num)



			i = gorila.make_list_personnel_new("'{0}'".format(sys.argv[i+2]))
			
			print "\n Numero de docentes que entraram nos varios anos no estabelecimento {0}:\n".format(sys.argv[i+2])
			for num in i:
				print "	 {0}\n".format(num)
		
		
		
		if(sys.argv[i]=="-e"):
			s = sys.argv[i+1]
			q = int(s[3])
			
			c = gorila.count_teachers_Year_estab(q, "'{0}'".format(sys.argv[i+2]))

			print "numero total de docentes por estabelecimento e por ano {0}".format(q)
			
			
		if(sys.argv[i]=="-d"):
			s = sys.argv[i+2]
			q = int(s[3])
			
			d = gorila.count_teachers_degree("'{0}'".format(sys.argv[i+1]), q)
		
			print "numero total de docentes por grau e por ano {0}".format(d)
			
		if(sys.argv[i]=="-dE"):
			s = sys.argv[i+3]
			q = int(s[3])
			
			e = gorila.count_teachers_Year_degree_estab(0, "'{0}'".format(sys.argv[i+2]), "'{0}'".format(sys.argv[i+1]) )

			print "numero total de docentes por estabelecimento, ano e grau {0}".format(e)

